package com.chenjun.web.controller.sys;

import java.text.SimpleDateFormat;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chenjun.common.util.PrintData;
import com.chenjun.common.util.UploadUtil;

@Controller
@RequestMapping("/upload")
public class UploadController {
	
	private static final Logger LOGGER = Logger.getLogger(UploadController.class);
	
	private static SimpleDateFormat sfName = new SimpleDateFormat("yyyyMMddHHmmss");
	
	@RequestMapping(value = "/file", method = RequestMethod.POST)
    @ResponseBody
    public void uploadFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, String> map = UploadUtil.doUpload(request);
		PrintData.printJsonData(map, null, response);
    }
	
}
